<template>
  <div class="Home" @touchmove="mousemove()" @touchend="mouseend()">
      <div class="Homeheader">
        <div class="sreach">
          <i class="iconfont icon-sousuokuangneiSearchIcon"></i>
          <input type="text" placeholder="搜索····"/>
        </div>
        <div class="carts"><i class="iconfont icon-shoppingCart-full" id="gouwuche"></i></div>
      </div>
      <div class="official flex-display">
        <router-link v-for="(item,idx) in gdata" :key="idx" :to="{path:'/classify', query: {code:item.code}}">
          <span>{{item.name}}</span>
        </router-link>
      </div>
      <Home-Swipe></Home-Swipe>
      <Home-List></Home-List>
      <Home-Container ></Home-Container>
      <ComFooter />
</div>
</template>

<script>
import api from "@/fetch/api"
import { mapState,mapMutations,mapGetters  } from 'vuex';

import { Swipe, SwipeItem } from 'mint-ui';
import { MessageBox } from 'mint-ui';

import HomeSwipe from './component/HomeSwipe';
import HomeList from './component/HomeList';
import HomeContainer from './component/HomeContainer'
import ComFooter from '@/common/ComFooter'
export default {
  name:"Home",
  data(){
    return{
      gdata:[],
      ethelWxUserInfo:'',
      arr:[],
    }
  },
  components:{
    HomeSwipe,
    HomeList,
    HomeContainer,
    ComFooter
  },
  mounted:function(){
    this.getGoodsList();
  },
  created() {
    // document.title = '艾瑟尔ETHEL'
    // //微信分享
    // var wxShareOpts = {
    //   title: '艾瑟尔ETHEL',
    //   desc: '艾瑟尔ETHEL是一家集生产、研发、智能科技美肤于一体的集团化公司，经营范围涉及生物技术推广服务、生物技术开发服务、生物产品的销售、生物产品的销售。',
    //   link: window.location.href.split('#')[0],
    //   img: 'http://ethelwap.sailafeina.com/static/img/slfn-logo.379828f.jpg'
    // }
    // console.log(wxShareOpts)
    this.wxShare(wxShareOpts);
  },
  methods: {
    mousemove(e){
      var e = e ||window.event
      var endX = e.touches[0].clientX;
      this.arr.push(endX)
    },
    mouseend(){
      if(this.arr[0]-this.arr[this.arr.length-1]>150){
        this.$router.push({
          path: "/classify"
        }) 
      }else if(this.arr[0]-this.arr[this.arr.length-1]<-150){
        // this.$router.push({
        //   path: "/home"
        // }) 
      }
      this.arr=[]
    },

    // 请求顶部tab列表
    getGoodsList: function(){
      const params = {};
      api.apparatusGoodsList(params)
        .catch(res => {
          this.print(res);
          this.gdata = res.data;
        })
    },
    hs(){
      console.log("666")
      this.ethelWxUserInfo = JSON.parse(window.localStorage.getItem(this.companyUnique));
      // console.log(this.ethelWxUserInfo)
      if(this.ethelWxUserInfo==null){
        console.log("666")
        this.$router.push('/entry/register'); 
      }
      
    }
  }
}
</script>

<style>

  .Home{
    border-bottom: 0.37rem;
    font-size: 0.74rem;
    background: #fff;
  }
  .Homeheader i{
    font-size: 0.55rem;
    margin-right:  0.37rem;
    color:#999;
  }
  #gouwuche {
    margin-left: 0.17rem;

  }
  .Homeheader .carts{
    width: 1.1rem;
    height: 1.4rem;
    float:right;
    line-height: 1.64rem;
    margin-right: .35rem;
  }
  .Homeheader .sreach {
    padding-left: 0.37rem;
    color:#ccc;
    width: 7.54rem;
    height: 0.8rem;
    line-height: 0.8rem;
    margin-top: 0.375rem;
    float:left;
    border:1px solid #ccc;
    border-radius: 1rem;
    margin-left: .6rem;

  }
  .Homeheader input {
    color:#000;
  }
   .Homeheader{
     width: 100%;
     top: 0;
     z-index: 1;
     height: 1.4rem;
     line-height: 1.3rem;
     font-size: 0.35rem;
     padding-left: 0rem;

   }
   .swipe{
     height: 6.5rem;
     margin-top: 1px;
   }
   .swipe img{
      width: 100%;
      height: 6.5rem;
  }

    .official{
      width: 100%;
      height: 0.8rem;
      padding-top: 0.2rem;
      margin-bottom: 0.2rem;
    }
    .official a{
      display: block;
      box-flex:1;
      -webkit-box-flex:1;
      flex:1;
      -webkit-flex:1;
      text-align: center;
    }
</style>
